package cli

import (
	"shqsoft.cn/pasnj/bi/cube"
	"shqsoft.cn/pasnj/bi/dictionary"
)

func buildAll(refresh bool) error {
	err := cube.BuildAll(refresh)
	if err != nil {
		return err
	}
	return err
}
func buildDimension(dimName string) (err error) {
	if dimName == "all" {
		err = cube.BuildAllDimension()
	} else {
		err = cube.BuildDimensionByName(dimName)
	}
	return
}
func buildCube(cubeName string, date string, refresh bool) (err error) {
	if cubeName == "all" {
		err = cube.BuildAllBube(refresh)
	} else {
		err = cube.BuildCubeByName(cubeName, date, refresh)
	}
	return nil
}
func buildDivision(diviName, date string) (err error) {
	if diviName == "all" {
		err = cube.BuildAllDivision(date)
	} else {
		err = cube.BuildDivision(diviName, date)
	}
	return err
}
func buildShare() (err error) {
	diviNames := []string{"comp_acco_divi", "comp_acco_oper", "comp_clie_divi", "indi_acco_divi", "indi_fana_divi", "indi_loan_divi", "indi_clie_divi", "comp_qtzb_divi", "indi_qtzb_divi"}
	for _, dt := range diviNames {
		div, err := cube.GetShare(dt)
		if err != nil {
			return err
		}
		err = div.Build()
		if err != nil {
			return err
		}
	}
	return nil
}
func buildDictionary() (err error) {
	err = dictionary.NewDepartment().Build()
	if err != nil {
		return
	}
	err = dictionary.NewEmployee().Build()
	return
}
